package be.kuleuven.peno3.mobiletoledo.model;

     
public class Schedule {                                                                                                                                            

	private CourseActivity[] courseActivitiesList;
	
	
	/*
	 * Constructor
	 * 
	 * @param Calendar begin: from what date the schedule starts
	 * @param Calendar end: the date the schedule ends
	 * @param String course: the course you want in your list ("all" of you want all courses in your list)
	 * @param String group: the group you belong to (null if you don't want to filter on your group)
	 */
	public Schedule(){
	}
//	public Schedule(Calendar begin,Calendar end,String course_id,String group,String study_programme){
//		courseActivitiesList=ScheduleClientDAO.getCourseActivities(begin,end,course_id,group,study_programme);
//		be.kuleuven.peno3.mobiletoledo.Data.LocalDAO db = new be.kuleuven.peno3.mobiletoledo.Data.LocalDAO(null);
//		String schedNameID = "Schedule_" + begin.getTimeInMillis() + "_" + end.getTimeInMillis() + "_" + course_id + "_" + group;
//		
//		if(courseActivitiesList == null){
//			try {
//				ByteArrayInputStream bis = new ByteArrayInputStream(db.fetchBlob(schedNameID));
//				ObjectInput in = new ObjectInputStream(bis);
//				Schedule sched = (Schedule) in.readObject();
//				courseActivitiesList = sched.getActivities();
//			} catch (StreamCorruptedException e) {
//				e.printStackTrace();
//			} catch (IOException e) {
//				e.printStackTrace();
//			} catch (ClassNotFoundException e) {
//				e.printStackTrace();
//			}
//		}
//		else {
//			if(db.fetchBlob(schedNameID) == null){
//				try {
//					ByteArrayOutputStream bos = new ByteArrayOutputStream();
//					ObjectOutput out;
//					out = new ObjectOutputStream(bos);
//					out.writeObject(this);
//					db.createBlob(schedNameID, bos.toByteArray()); 
//				} catch (IOException e) {
//					e.printStackTrace();
//				}   
//			}
//			else {
//				try {
//					ByteArrayOutputStream bos = new ByteArrayOutputStream();
//					ObjectOutput out;
//					out = new ObjectOutputStream(bos);
//					out.writeObject(this);
//					db.updateBlob(schedNameID, bos.toByteArray()); 
//				} catch (IOException e) {
//					e.printStackTrace();
//				}   
//			}
//		}
//	}
	
	public CourseActivity[] getActivities() {
		return courseActivitiesList;
	}
    public void setCourseActivities(CourseActivity[] courseActivities){
    	courseActivitiesList = courseActivities;
    }
	
}
